<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8 " />
<title></title>
<style type="text/css">
#tree {
    width: 150px;
}
#tree, #tree ul {
    list-style: none; margin: 0; padding: 0; padding: 10px;
}
#tree li {
    border: 1px solid #00f; padding: 10px; cursor: pointer;
}
#tree ul {
    display: none;
}
</style>
<script type="text/javascript">
window.onload = function() {
    var tree = document.getElementById("tree");
    var lis = tree.getElementsByTagName("li");
    for(var i = 0; i < lis.length; i++) {
        (function(a) {
            lis[a].onclick = function() {
                if(typeof this.getElementsByTagName("ul") !== null) {
                    var ul_first = this.getElementsByTagName("ul")[0];
                    if(ul_first.style.display == "block")
                        ul_first.style.display = "none";
                    else
                        ul_first.style.display = "block";
                }
            };
        })(i);
    }
};
</script>
</head>
<body>
<ul id="tree">
<li>菜单一
<ul>
<li>1-1</li><li>1-2</li><li>1-3</li><li>1-4</li>
</ul>
</li>
<li>菜单二
<ul>
<li>2-1</li><li>2-2</li><li>2-3</li><li>2-4</li>
</ul>
</li>
<li>菜单三
<ul>
<li>3-1</li><li>3-2</li><li>3-3</li><li>3-4</li>
</ul>
</li>
</ul>
</body>
</html>